module.exports = app => {
    const seq = app.Sequelize;

    const Wechat = app.model.define('wechat', {
        id:{
            type:seq.INTEGER,
            autoIncrement:true,
            allowNull:false,
            primaryKey:true,
            unique:true
        },
        appId:{
            type:seq.STRING,
            allowNull:false
        },
        appSecret: {
            type:seq.STRING,
            allowNull:false
        },
        token: {
            type:seq.STRING,
            allowNull:true,
        },
        accessToken:{
            type:seq.STRING,
            allowNull:true,
        },
        type:{
            type:seq.INTEGER,
            allowNull:true,
            defaultValue:0
        },
        name:{
            type:seq.STRING,
            allowNull:true,
        }
    },{
        timestamps:true,
        paranoid:true,
        underscored:false
    });

    Wechat.associate=function () {
        app.model.Wechat.belongsTo(app.model.Admin);
        app.model.Wechat.hasMany(app.model.User);
        app.model.Wechat.hasMany(app.model.Banner);
        app.model.Wechat.hasMany(app.model.Menu);
        app.model.Wechat.hasMany(app.model.Form);
        app.model.Wechat.hasMany(app.model.Tag);
        app.model.Wechat.hasMany(app.model.Class);
        app.model.Wechat.hasMany(app.model.Brand);
    };


    return Wechat;
};